package com.pp.buvaka.table;


import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

public class Field {
    private String value;

    public Field(String value){
        setValue(value);
    }
    public Field (double value) {
        String val = ""+value;
        setValue(val);
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString(){

        DecimalFormat formatter = new DecimalFormat();
        DecimalFormatSymbols df = new DecimalFormatSymbols();
        df.setDecimalSeparator(',');
        formatter.setDecimalFormatSymbols(df);

        try {
            double res = Double.parseDouble(value);
            if (Double.isNaN(res))
                return "#";
            else
                return formatter.format(res);
        } catch (NumberFormatException exc){
            return value;
        }

    }
}
